<?php
function err2 ($str)
{
    global $ui;
    $ui->showErrorPage("<table width=242 border=1 cellpadding=6 cellspacing=0 align=center>" . ( "<tr align=center><td bgcolor=red><font color=white><b>" ) . $str . "</b></font></td></tr></table><br>" . "<p><input type=button value=关闭 onclick=\"window.top.mainFrame.myCloseMyDiv(0);\"></p>" . "<script>" . "setTimeout(\"if(window.top.mainFrame){ window.top.mainFrame.myCloseMyDiv(0);}\",3000);" . "</script>");
    exit();
}

function save2bet2 ($uid, $acl, $pid, $btype, $order, $num, $money, $rate, $u2, $u3, $u4, $u5, $stime)
{
    global $lotto_id;
    global $prot_start;
    global $conf;
    global $lotto6h;
    $fields = array();
    $fields['user_id'] = $uid;
    $fields['prev_id'] = $pid;
    $fields['acl'] = $acl;
    $fields['lotto_id'] = $lotto_id;
    $fields['createtime'] = $stime;
    $fields['bettype'] = $btype;
    if ($btype == 19 || $btype == 27 || $btype == 36)
    {
        $fields['numbers'] = "'{$order}|{$num}'";
    }
    else
    {
        $fields['numbers'] = "'{$order} {$num}'";
    }
    $fields['amount'] = $money;
    $fields['rate'] = $rate;
    $fields['line_nums'] = "'{$num}'";
    $fields['unitmoney'] = $money;
    if ($fields['rate'] <= 0 || $fields['amount'] <= 0)
    {
        return 0 - 1;
    }
    $bttt = $btype;
    if ($btype == 24)
    {
        $bttt = 0;
    }
    if ($btype == 26)
    {
        $bttt = 25;
    }
    if ($acl < 5)
    {
        $rsu = get_srates_data($uid, $lotto_id, $btype, $order);
        $tempArr = array(15, 16, 17, 23);
        if (in_array($btype, $tempArr))
        {
            $subrates = $rsu->f["r15_{$order}_{$num}"] + 0;
        }
        else
        {
            $subrates = $rsu->f["r" . $num] + 0;
        }
    }
    else
    {
        $subrates = 0;
    }
    $rate0_8num = 0;
    $fields['rate2'] = 0;
    $fields['rate3'] = 0;
    $fields['rate4'] = 0;
    $fields['rate5'] = 0;
    $percent_sw = $u5['percent_sw'];
    if ($u5['reat0_8_open'] == 1)
    {
        $rate0_8num = 0.04;
    }
    if ($acl == 2)
    {
        $fields['uperid3'] = $u2['prev_id'];
        $fields['uperid4'] = $u3['prev_id'];
        $fields['uperid5'] = $u4['prev_id'];
        if ($btype == 19)
        {
            if (intval($conf->get("reat0_open")) == 1 && $u5['reat0_open'] == 1)
            {
                $fields['rate2'] = $u2['rate0'] * $rate0_8num;
                $fields['rate3'] = $u3['rate0'] * $rate0_8num;
                $fields['rate4'] = $u4['rate0'] * $rate0_8num;
            }
            $fields['rate5'] = $subrates;
        }
        else if ($btype == 25 || $btype == 26)
        {
            $fields['rate5'] = $subrates;
        }
        $fields['back2'] = GetBack($u2['id'], $bttt, 1, 2);
        $fields['back3'] = GetBack($u3['id'], $bttt, 1, 3);
        $fields['back4'] = GetBack($u4['id'], $bttt, 1, 4);
        $fields['back5'] = GetBack($u5['id'], $bttt, 1, 5);
        $fields['back6'] = GetBack($u5['supe_account'], $bttt, 1, 255);
        $fields['percent3'] = $u2['percent0'];
        $fields['percent4'] = $u3['percent0'];
        if ($percent_sw == 1)
        {
            $fields['percent5'] = $u5['mpercent'] - $fields['percent4'] - $fields['percent3'];
        }
        else
        {
            $fields['percent5'] = $u4['percent0'];
        }
        $fields['r2'] = $money * $fields['percent3'] / 100;
        $fields['r3'] = $money * $fields['percent4'] / 100;
        $fields['r4'] = $money * $fields['percent5'] / 100;
    }
    else if ($acl == 3)
    {
        $fields['uperid3'] = $uid;
        $fields['uperid4'] = $u3['prev_id'];
        $fields['uperid5'] = $u4['prev_id'];
        if ($btype == 19)
        {
            if (intval($conf->get("reat0_open")) == 1 && $u5['reat0_open'] == 1)
            {
                $fields['rate3'] = $u3['rate0'] * $rate0_8num;
                $fields['rate4'] = $u4['rate0'] * $rate0_8num;
            }
            $fields['rate5'] = $subrates;
        }
        else if ($btype == 25 || $btype == 26)
        {
            $fields['rate5'] = $subrates;
        }
        $fields['back2'] = 100;
        $fields['back3'] = GetBack($u3['id'], $bttt, 1, 3);
        $fields['back4'] = GetBack($u4['id'], $bttt, 1, 4);
        $fields['back5'] = GetBack($u5['id'], $bttt, 1, 5);
        $fields['back6'] = GetBack($u5['supe_account'], $bttt, 1, 255);
        $fields['percent3'] = 0;
        $fields['percent4'] = $u3['percent2'];
        if ($percent_sw == 1)
        {
            $fields['percent5'] = $u5['mpercent'] - $fields['percent4'];
        }
        else
        {
            $fields['percent5'] = $u4['percent0'];
        }
        $fields['r3'] = $money * $fields['percent4'] / 100;
        $fields['r4'] = $money * $fields['percent5'] / 100;
    }
    else if ($acl == 4)
    {
        $fields['uperid4'] = $uid;
        $fields['uperid5'] = $u4['prev_id'];
        if ($btype == 19)
        {
            if (intval($conf->get("reat0_open")) == 1 && $u5['reat0_open'] == 1)
            {
                $fields['rate4'] = $u4['rate0'] * $rate0_8num;
            }
            $fields['rate5'] = $subrates;
        }
        else if ($btype == 25 || $btype == 26)
        {
            $fields['rate5'] = $subrates;
        }
        $fields['back2'] = 100;
        $fields['back3'] = 100;
        $fields['back4'] = GetBack($u4['id'], $bttt, 1, 4);
        $fields['back5'] = GetBack($u5['id'], $bttt, 1, 5);
        $fields['back6'] = GetBack($u5['supe_account'], $bttt, 1, 255);
        $fields['percent3'] = 0;
        $fields['percent4'] = 0;
        $fields['percent5'] = $u4['percent2'];
        $fields['r4'] = $money * $fields['percent5'] / 100;
    }
    else if ($acl == 5)
    {
        $fields['uperid5'] = $uid;
        $fields['back2'] = 100;
        $fields['back3'] = 100;
        $fields['back4'] = 100;
        $fields['back5'] = GetBack($u5['id'], $bttt, 1, 5);
        $fields['back6'] = GetBack($u5['supe_account'], $bttt, 1, 255);
        $fields['percent3'] = 0;
        $fields['percent4'] = 0;
        $fields['percent5'] = 0;
    }
    $fields['percent255'] = max(100 - $fields['percent5'] - $fields['percent4'] - $fields['percent3'], 0);
    $protmod = $u5['protmod'];
    $fields['r6'] = $money * $fields['percent255'] / 100;
    $fields['betmode'] = 1;
    $fields['ip'] = "'" . getIP() . "'";
    $newid = db_insert("bet2", $fields);
    if ($btype == 19)
    {
        check_autorate($lotto_id, $btype, "{$order}|{$num}", $fields['r6']);
    }
    else if ($btype != 27 && $btype != 36)
    {
        check_autorate($lotto_id, $btype, "{$order} {$num}", $fields['r6']);
    }
    $lotto6h->getBet2_6h($newid);
}

if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$ui = new UI();
if ($curruser['acl'] == 5 && $curruser['percent_sw'] == 1)
{
    err("你是固定占成的大股东，不能走飞！");
}
$conf = new Config();
include_once( "class_6h/class.lotto6h.php" );
$lotto6h = new lotto6h();
$ok = isset($_POST['ok']);
if (!$ok)
{
    $bettype = explode(",", $_GET['btype']);
    $orderid = explode(",", $_GET['ord']);
    $numbers = explode(",", $_GET['num']);
    $rate = explode(",", $_GET['rate']);
    $amount = explode(",", $_GET['amount']);
    $maxchk = explode(",", $_GET['chk']);
    $count = count($numbers);
    if ($count == 0)
    {
        err2("错误的参数！");
    }
    echo "<body onload='StartFocus()'>";
}
else
{
    echo "<body>";
}
$startbet = $conf->get("startbet");
$stopbet = $conf->get("stopbet");
$waitbet = $conf->get("waitbet");
$prot_start = $conf->get("protect_start");
$betmin = $conf->get("betmin");
echo "<form action=\"op.php?op=agent&fp=protsaves2\" method=post onsubmit=\"this.submit.disabled=true;this.reset.disabled=true\">";
echo "<input type=hidden name=ok value=1>";
global $curruser;
$user = new User();
if ($curruser['enabled'] == 0 || $curruser['enabled'] == 2)
{
    err2("帐号已被暂停使用！");
}
$rs = getdb("select * from lotto where open>='" . date("Y-m-d") . "' order by open");
if ($rs->eof)
{
    err2("目前没有可以下注期数！");
}
$open = $rs->f['open'];
$lotto_id = $rs->f['id'];
$lotto_ns = $rs->f['n1'] + $rs->f['n2'] + $rs->f['n3'] + $rs->f['n4'] + $rs->f['n5'] + $rs->f['n6'];
if (date("Y-m-d") == $open)
{
    if (date("Hi") < $startbet)
    {
        err2("本期尚未开盘！");
    }
    if ($waitbet <= date("Hi") || $stopbet <= date("Hi") || 0 < $lotto_ns)
    {
        err2("已经截止下注！");
    }
}
else
{
    err2("本期尚未开盘！");
}
if ($prot_start == 0)
{
    err2("尚未开放走飞补货功能！");
}
$userid = $curruser['id'];
$acl = $curruser['acl'];
$previd = $curruser['prev_id'];
$n = 0;
if ($acl == 2)
{
    $u2 = get_user($userid);
    $u3 = get_user($u2['prev_id']);
    $u4 = get_user($u3['prev_id']);
    $u5 = get_user($u4['prev_id']);
    $protmod = $u5['protmod'];
}
else if ($acl == 3)
{
    $u2 = "";
    $u3 = get_user($userid);
    $u4 = get_user($u3['prev_id']);
    $u5 = get_user($u4['prev_id']);
    $protmod = $u5['protmod'];
}
else if ($acl == 4)
{
    $u2 = "";
    $u3 = "";
    $u4 = get_user($userid);
    $u5 = get_user($u4['prev_id']);
    $protmod = $u5['protmod'];
}
else if ($acl == 5)
{
    $u2 = "";
    $u3 = "";
    $u4 = "";
    $u5 = get_user($userid);
    $protmod = $u5['protmod'];
}
if ($ok)
{
    $bettype = $_POST['btype'];
    $orderid = $_POST['ord'];
    $numbers = $_POST['num'];
    $rate = $_POST['rate'];
    $amount = $_POST['amount'];
    $maxchk = $_POST['mchk'];
    $count = count($numbers);
    if ($rate == 0)
    {
        err("没有设置赔率！");
    }
    $waittime = 50;
    $usedamountx = array();
    $n = 0;
    $i = 0;
    while ($i < $count)
    {
        $usedamountx[$i] = 0;
        if (0 < $amount[$i])
        {
            $bettype[$i] = intval($bettype[$i]);
            $orderid[$i] = intval($orderid[$i]);
            ++$n;
        }
        ++$i;
    }
    if ($n)
    {
        $rs = getdb("!!select sum(amount) from bet2 where user_id=" . $userid . " and lotto_id=" . $lotto_id . " and rame=0");
        $usedamount = $rs->f[0] ? $rs->f[0] : 0;
        $rs->close();
        $users = GetUserList($userid);
        if ($users != "")
        {
            if ($acl == 2)
            {
                $rs = getdb("!!select sum(amount),sum(amount*mpercent/100) from bet where user_id in (" . $users . ") and lotto_id=" . $lotto_id . " and rame=0");
            }
            else if ($acl == 3)
            {
                $rs = getdb("!!select sum(amount),sum(amount*percent2/100) from bet where user_id in (" . $users . ") and lotto_id=" . $lotto_id . " and rame=0");
            }
            else if ($acl == 4)
            {
                $rs = getdb("!!select sum(amount),sum(amount*percent3/100) from bet where user_id in (" . $users . ") and lotto_id=" . $lotto_id . " and rame=0");
            }
            else if ($acl == 5)
            {
                $rs = getdb("!!select sum(amount),sum(amount*percent4/100) from bet where user_id in (" . $users . ") and lotto_id=" . $lotto_id . " and rame=0");
            }
            $usedamount += $rs->f[0] ? $rs->f[0] : 0;
            $rs->close();
        }
        $usemaxamount = $curruser['usemaxamount'];
        echo "<table width=262 border=1 cellpadding=4 cellspacing=0 align=center>";
        echo "<tr class=td0><td nowrap>走飞内容<td nowrap>赔率<td nowrap>走飞金额<td nowrap>验证结果";
        $total = 0;
        $i = 0;
        while ($i < $count)
        {
            $rs = getdb("select * from amounts where user_id=" . $userid . " and bettype=" . $bettype[$i]);
            $amount1 = $rs->f['amount1'];
            $amount2 = $rs->f['amount2'];
            $rs->close();
            $chk_rate = 0;
            switch ($bettype[$i])
            {
                case 25 :
                case 26 :
                    $rs0 = getdb("select * from rate4" . $orderid[$i] . "a where lotto_id=" . $lotto_id);
                    $rsu = get_srates_data($userid, $lotto_id, 25, $orderid[$i]);
                    if ($acl < 5 && $rsu != false && $rsu->eof != true)
                    {
                        $tempRate = $rsu->f["r" . $numbers[$i]];
                    }
                    else
                    {
                        $tempRate = 0;
                    }
                    if ($rate[$i] != $rs0->f["r" . $numbers[$i]] - $tempRate)
                    {
                        $rate[$i] = $rs0->f["r" . $numbers[$i]] - $tempRate;
                        $chk_rate = 1;
                    }
                    break;
            }
            if ($bettype[$i] == 25 || $bettype[$i] == 26)
            {
                if ($users != "")
                {
                    if ($acl == 2)
                    {
                        $rsx = getdb("!!select sum(amount*mpercent/100) from bet where user_id in (" . $users . ") and lotto_id=" . $lotto_id . " and numbers='" . $orderid[$i] . " " . $numbers[$i] . "' and bettype in (25,26) and rame=0");
                        $usedamountx[$i] = $rsx->f[0];
                    }
                    else if ($acl == 3)
                    {
                        $rsx = getdb("!!select sum(amount*percent2/100) from bet where user_id in (" . $users . ") and lotto_id=" . $lotto_id . " and numbers='" . $orderid[$i] . " " . $numbers[$i] . "' and bettype in (25,26) and rame=0");
                        $usedamountx[$i] = $rsx->f[0];
                        $rsz = getdb("!!select sum(amount*percent" . $acl . "/100) from bet2 where lotto_id=" . $lotto_id . " and uperid" . $acl . "=" . $userid . " and user_id!=" . $userid . " and bettype in (25,26) and numbers='" . $orderid[$i] . " " . $numbers[$i] . "' and rame=0");
                        $usedamountx[$i] += $rsz->f[0] ? $rsz->f[0] : 0;
                    }
                    else if ($acl == 4)
                    {
                        $rsx = getdb("!!select sum(amount*percent3/100) from bet where user_id in (" . $users . ") and lotto_id=" . $lotto_id . " and numbers='" . $orderid[$i] . " " . $numbers[$i] . "' and bettype in (25,26) and rame=0");
                        $usedamountx[$i] = $rsx->f[0];
                        $rsz = getdb("!!select sum(amount*percent" . $acl . "/100) from bet2 where lotto_id=" . $lotto_id . " and uperid" . $acl . "=" . $userid . " and user_id!=" . $userid . " and bettype in (25,26) and numbers='" . $orderid[$i] . " " . $numbers[$i] . "' and rame=0");
                        $usedamountx[$i] += $rsz->f[0] ? $rsz->f[0] : 0;
                    }
                    else
                    {
                        $rsx = getdb("!!select sum(amount*percent4/100) from bet where user_id in (" . $users . ") and lotto_id=" . $lotto_id . " and numbers='" . $orderid[$i] . " " . $numbers[$i] . "' and bettype in (25,26) and rame=0");
                        $usedamountx[$i] = $rsx->f[0];
                        $rsz = getdb("!!select sum(amount*percent" . $acl . "/100) from bet2 where lotto_id=" . $lotto_id . " and uperid" . $acl . "=" . $userid . " and user_id!=" . $userid . " and bettype in (25,26) and numbers='" . $orderid[$i] . " " . $numbers[$i] . "' and rame=0");
                        $usedamountx[$i] += $rsz->f[0] ? $rsz->f[0] : 0;
                    }
                }
                $rs2 = getdb("!!select sum(amount) from bet2 where bettype in (25,26) and numbers='" . $orderid[$i] . " " . $numbers[$i] . "' and user_id=" . $userid . " and lotto_id=" . $lotto_id . " and rame=0");
            }
            else
            {
                if ($users != "")
                {
                    if ($acl == 2)
                    {
                        $rsx = getdb("!!select sum(amount*mpercent/100) from bet where user_id in (" . $users . ") and lotto_id=" . $lotto_id . " and bettype=" . $bettype[$i] . " and numbers like '" . $orderid[$i] . " %' and rame=0");
                        $usedamountx[$i] = $rsx->f[0];
                    }
                    else if ($acl == 3)
                    {
                        $rsx = getdb("!!select sum(amount*percent2/100) from bet where user_id in (" . $users . ") and lotto_id=" . $lotto_id . " and bettype=" . $bettype[$i] . " and numbers like '" . $orderid[$i] . " %' and rame=0");
                        $usedamountx[$i] = $rsx->f[0];
                        $rsz = getdb("!!select sum(amount*percent" . $acl . "/100) from bet2 where lotto_id=" . $lotto_id . " and uperid" . $acl . "=" . $userid . " and user_id!=" . $userid . " and bettype=" . $bettype[$i] . " and numbers like '" . $orderid[$i] . " %' and rame=0");
                        $usedamountx[$i] += $rsz->f[0] ? $rsz->f[0] : 0;
                    }
                    else if ($acl == 4)
                    {
                        $rsx = getdb("!!select sum(amount*percent3/100) from bet where user_id in (" . $users . ") and lotto_id=" . $lotto_id . " and bettype=" . $bettype[$i] . " and numbers like '" . $orderid[$i] . " %' and rame=0");
                        $usedamountx[$i] = $rsx->f[0];
                        $rsz = getdb("!!select sum(amount*percent" . $acl . "/100) from bet2 where lotto_id=" . $lotto_id . " and uperid" . $acl . "=" . $userid . " and user_id!=" . $userid . " and bettype=" . $bettype[$i] . " and numbers like '" . $orderid[$i] . " %' and rame=0");
                        $usedamountx[$i] += $rsz->f[0] ? $rsz->f[0] : 0;
                    }
                    else
                    {
                        $rsx = getdb("!!select sum(amount*percent4/100) from bet where user_id in (" . $users . ") and lotto_id=" . $lotto_id . " and bettype=" . $bettype[$i] . " and numbers like '" . $orderid[$i] . " %' and rame=0");
                        $usedamountx[$i] = $rsx->f[0];
                        $rsz = getdb("!!select sum(amount*percent" . $acl . "/100) from bet2 where lotto_id=" . $lotto_id . " and uperid" . $acl . "=" . $userid . " and user_id!=" . $userid . " and bettype=" . $bettype[$i] . " and numbers like '" . $orderid[$i] . " %' and rame=0");
                        $usedamountx[$i] += $rsz->f[0] ? $rsz->f[0] : 0;
                    }
                }
                $rs2 = getdb("!!select sum(amount) from bet2 where bettype=" . $bettype[$i] . " and numbers like '" . $orderid[$i] . " %' and user_id=" . $userid . " and lotto_id=" . $lotto_id . " and rame=0");
            }
            $numberamount = $rs2->f[0] ? intval($rs2->f[0]) : 0;
            $rs2->close();
            $usedamountx[$i] = intval($usedamountx[$i]) - $numberamount;
            echo "<tr align=right class=td2 onmouseover=msover() onmouseout=msout() valign=top>";
            echo "<td nowrap>" . GetBetContent($bettype[$i], $orderid[$i] . " " . $numbers[$i], $amount[$i]);
            echo "<td nowrap>" . floatval($rate[$i]);
            echo "<td nowrap>" . intval($amount[$i]) . "<td>";
            if (0 < $amount[$i] && $amount[$i] < $betmin)
            {
                $n = 0;
                $waittime = 3000;
                echo "<font color=red>低於最小注额</font>";
            }
            else if ($curruser['amount'] < $amount[$i] + $total + $usedamount)
            {
                $n = 0;
                $waittime = 3000;
                echo "<font color=red>超过信用额度</font>";
            }
            else if ($amount1 < $amount[$i])
            {
                $n = 0;
                $waittime = 3000;
                echo "<font color=red>超过单注限额</font>";
            }
            else if ($amount2 < $amount[$i] + $numberamount)
            {
                $n = 0;
                $waittime = 3000;
                echo "<font color=red>超过单项限额</font>";
            }
            else if ($usedamountx[$i] - 0 < $maxchk[$i] - 0 && $amount[$i] - 0 == $maxchk[$i] - 0)
            {
                $n = 0;
                $waittime = 5000;
                write_exceptional_log($userid, $acl, $lotto_id, "使用不正常方式走飞下注（" . $numbers[$i] . " ＄ " . $amount[$i] . "）");
                echo "<font color=red>禁用外挂下注</font>";
            }
            else if ($usedamountx[$i] - 0 < $amount[$i])
            {
                $n = 0;
                $waittime = 3000;
                echo "<font color=red>超过下注金额</font>";
            }
            else if ($usemaxamount && $curruser['maxamount'] < $amount[$i] + $usedamount)
            {
                $n = 0;
                $waittime = 3000;
                echo "<font color=red>超过本期限额</font>";
            }
            else if ($rate[$i] <= 1)
            {
                $n = 0;
                $waittime = 3000;
                echo "<font color=red>赔率设置错误</font>";
            }
            else if ($waitbet <= date("Hi"))
            {
                $n = 0;
                $waittime = 5000;
                echo "<font color=red>已经截止下注</font>";
            }
            else if ($chk_rate == 1)
            {
                echo "<font color=green>赔率已经更动</font>";
            }
            else
            {
                echo "<font color=green>已存档成功！</font>";
            }
            $total += intval($amount[$i]);
            ++$i;
        }
        echo "<tr class=td1><td colspan=2 align=right><b>合计 " . $count . " 笔</b>";
        echo "<td align=right nowrap><b>" . $total . "</b><td>";
        echo "</td></tr></table>";
    }
    if ($n)
    {
        $stime = systime();
        $i = 0;
        while ($i < $count)
        {
            if (0 < $amount[$i])
            {
                save2bet2($userid, $acl, $previd, $bettype[$i], $orderid[$i], $numbers[$i], $amount[$i], $rate[$i], $u2, $u3, $u4, $u5, $stime);
            }
            ++$i;
        }
        echo "<table width=262 border=1 cellpadding=6 cellspacing=0 align=center>";
        echo "<tr align=center><td bgcolor=green><font color=white><b>补货走飞完成！<br />5秒後自动关闭画面</b></font></td></tr></table>";
        echo "<script>";
        echo "setTimeout(\"if(window.top.mainFrame){ window.top.mainFrame.myCloseMyDiv(1); }\",5500);";
        echo "</script>";
    }
    else
    {
        if (100 < $waittime)
        {
            echo "<table width=262 border=1 cellpadding=6 cellspacing=0 align=center>";
            $tmpW = intval($waittime / 1000);
            echo "<tr align=center><td bgcolor=red><font color=white><b>补货走飞失败！<br />{$tmpW}秒後自动关闭画面</b></font></td></tr></table>";
        }
        echo "<script>";
        echo "setTimeout(\"if(window.top.mainFrame){ window.top.mainFrame.myCloseMyDiv(0); }\"," . $waittime . ");";
        echo "</script>";
    }
}
else if (0 < $protmod)
{
    echo "<table width=262 border=1 cellpadding=1 cellspacing=0 align=center>";
    echo "<tr class=td0><td nowrap>走飞内容<td nowrap>赔率<td nowrap>下注金额<td nowrap>走飞金额";
    $total = 0;
    $i = 0;
    while ($i < $count)
    {
        if (0 < $amount[$i])
        {
            switch ($bettype[$i])
            {
                case 25 :
                case 26 :
                    $rs0 = getdb("select * from rate4" . $orderid[$i] . "a where lotto_id=" . $lotto_id);
                    $rsu = get_srates_data($userid, $lotto_id, 25, $orderid[$i]);
                    if ($acl < 5 && $rsu != false && $rsu->eof != true)
                    {
                        $tempRate = $rsu->f["r" . $numbers[$i]];
                    }
                    else
                    {
                        $tempRate = 0;
                    }
                    if ($rate[$i] != $rs0->f["r" . $numbers[$i]] - $tempRate)
                    {
                        $rate[$i] = $rs0->f["r" . $numbers[$i]] - $tempRate;
                    }
                    break;
            }
            echo "<tr align=right class=td2 onmouseover=msover() onmouseout=msout() valign=top>";
            echo "<td nowrap>" . GetBetContent($bettype[$i], $orderid[$i] . " " . $numbers[$i], $amount[$i]);
            echo "<td nowrap>" . $rate[$i] . "</td>";
            echo "<td nowrap>" . $maxchk[$i] . "</td>";
            echo "<input type=hidden name=btype[] value=" . $bettype[$i] . ">";
            echo "<input type=hidden name=ord[] value=" . $orderid[$i] . ">";
            echo "<input type=hidden name=num[] value=" . $numbers[$i] . ">";
            echo "<input type=hidden name=rate[] value=" . $rate[$i] . ">";
            echo "<input type=hidden name=mchk[] value=" . $maxchk[$i] . ">";
            echo "<td nowrap><input name=amount[] value=" . $amount[$i] . " size=8 maxlength=8 onkeypress=\"return KeyNumber()\"></td>";
            $total += $amount[$i];
        }
        ++$i;
    }
    echo "<tr class=td1><td colspan=2 align=right><b>合计 " . $count . " 笔</b>";
    echo "<td align=right nowrap><b>" . $total . "</b><td>";
    echo "</td></tr></table>";
    echo "<br><center><input type=submit name=submit value=确定>";
    echo "&#12288;&#12288;&#12288; <input name=reset type=reset value=取消 onclick=\"window.top.mainFrame.myCloseMyDiv(0);\"></center>";
    echo "</form>";
    echo "</body>";
    echo "<script>";
    echo "setTimeout(\"if(window.top.mainFrame) {window.top.mainFrame.myCloseMyDiv(0);}\",60000);";
    echo "</script>";
}
else
{
    err2("没有走飞权限！");
}
echo "\r\n";
echo "<S";
echo "cript>\r\nfunction StartFocus(){\r\n\tdocument.forms[0].submit.focus();\r\n}\r\n</Script>\r\n";
?>